package com.bnd.controller;

import com.bnd.config.SseEmitterUTF8;
import com.bnd.service.VoiceService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * 语音控制器
 */
@Slf4j
@RestController
@RequestMapping("/voice")
public class VoiceController {
    @Resource
    private VoiceService voiceService;

    /**
     * 根据音色ID播放音频
     * @param voiceId 语音ID
     * @return SSE连接
     */
    @GetMapping("/play")
    public SseEmitter playVoiceByVoiceId(@RequestParam(value = "voiceId") String voiceId){
        log.info("[语音播放] voiceId={}", voiceId);
        return voiceService.playVoiceByVoiceId(voiceId);
    }
}
